<template>
    <view>
        <view v-if="goods != null" class="page">
			<!-- #ifdef APP-PLUS -->
			<!-- 右侧icon -->
			<view class="top-share-right-icon">
			    <uni-icons type="redo" size="20" color="#333" class="icon round cp" @tap="popup_share_event"></uni-icons>
			</view>
			<!-- #endif -->
            <!-- 轮播图片 -->
            <swiper
                :indicator-dots="indicator_dots"
                :indicator-color="indicator_color"
                :indicator-active-color="indicator_active_color"
                :autoplay="autoplay"
                :circular="circular"
                class="goods-photo bg-grey"
                v-if="goods_photo.length > 0"
            >
                <block v-for="(item, index) in goods_photo" :key="index">
                    <swiper-item>
                        <image class="swiper-item wh-auto" @tap="goods_photo_view_event" :data-index="index" :src="item.images" mode="aspectFit" />
                    </swiper-item>
                </block>
            </swiper>

            <!-- 视频 -->
            <block v-if="goods.video.length > 0">
                <view v-if="goods_video_is_autoplay" class="goods-video">
                    <video
                        :src="goods.video"
                        :autoplay="goods_video_is_autoplay"
                        :show-center-play-btn="true"
                        :controls="false"
                        :show-play-btn="false"
                        :enable-progress-gesture="false"
                        :show-fullscreen-btn="false"
                    ></video>
                </view>
                <view class="goods-video-submit">
                    <image
                        v-if="!goods_video_is_autoplay"
                        class="goods-video-play"
                        @tap="goods_video_play_event"
                        :src="common_static_url+'video-play-icon.png'"
                        mode="aspectFit"
                    ></image>
                    <image
                        v-if="goods_video_is_autoplay"
                        class="goods-video-close"
                        @tap="goods_video_close_event"
                        :src="common_static_url+'video-close-icon.png'"
                        mode="aspectFit"
                    ></image>
                </view>
            </block>

            <!-- 倒计时 -->
            <view v-if="(daojishi_data || null) != null">
				<view class="daojishi">
					<image :src="cutprice_static_url+'mini/mengceng.png'" mode="scaleToFill" class="imgll" />
					<view class="countdown">
						<view class="pricebox">
							<text class="pin_price_symbol">{{ currency_symbol }}</text>
							<text class="pin_price">{{ goods.min_price }}</text>
							<text :class="'pin_price_qi '+$t('fengcheche.cutprice.app_lang')">{{$t('fengcheche.cutprice.list_price_before')}}</text>
						</view>
						<view :class="'rightcc '+$t('fengcheche.cutprice.app_lang')">
							<text class="t2">{{ groups_status_text }}</text>
							<text v-if="(goods.original_price || null) != null && goods.original_price != '0.00'" class="original-price">
								{{$t('fengcheche.cutprice.list_price_old_price')}}:{{ currency_symbol }}{{ goods.original_price }}
							</text>
						</view>
						<view v-if="goods.status == 1" class="time-right">
							<component-countdown :propTextTipsEnd="$t('fengcheche.cutprice.detail_cutdown_tips_2')" :propHour="daojishi_data.time.hours" :propMinute="daojishi_data.time.minutes" :propSecond="daojishi_data.time.seconds"></component-countdown>
						</view>
						<view v-else class="time-right overtt tr">{{$t('fengcheche.cutprice.detail_base_hd_over_tips')}}</view>
					</view>
				</view>
            </view>
			<view v-else>
				
			</view>

            <!-- 基础息 -->
            <view class="goods-base bg-white">
                <!-- 标题 -->
                <view class="goods-title multi-text" :style="'color:' + goods.title_color">{{ goods.title }}</view>
                <view class="goods-price">
                    <view class="goods-share tc" @tap="popup_share_event">
                        <image :src="cutprice_static_url+'mini/goods-detail-share-icon.png'" mode="scaleToFill" class="dis-block" />
                        <view class="cr-888 dis-none">{{$t('fengcheche.cutprice.detail_base_share_text')}}</view>
                    </view>
                    <view class="simple_desc">{{goods.groups_simple_desc}}</view>
                </view>
            </view>

            <view class="wanfa spacing">
                <view class="spacing-nav-title">
                    <text class="line"></text>
                    <text class="text-wrapper">{{$t('fengcheche.cutprice.detail_base_title_wanfa_text')}}</text>
                    <view class="seerule" @tap="popup_bang_event">{{$t('fengcheche.cutprice.detail_base_title_guize_text')}}</view>
                </view>
                <view class="wanfacc weui-flex bg-white">
                    <view class="weui-flex__item">
                        <view class="placeholder">
                            <text>1</text>
                            {{$t('fengcheche.cutprice.detail_base_title_guize_1')}}
                        </view>
                    </view>
                    <view class="weui-flex__item">
                        <view class="placeholder">
                            <text>2</text>
                            {{$t('fengcheche.cutprice.detail_base_title_guize_2')}}
                        </view>
                    </view>
                    <view class="weui-flex__item">
                        <view class="placeholder">
                            <text>3</text>
                            {{$t('fengcheche.cutprice.detail_base_title_guize_3')}}
                        </view>
                    </view>
                    <view class="weui-flex__item">
                        <view class="placeholder">
                            <text>4</text>
                            {{$t('fengcheche.cutprice.detail_base_title_guize_4')}}
                        </view>
                    </view>
                </view>
            </view>

            <!--商品评论展示2条-->
            <view class="pinglun spacing" v-if="goods.comments_count > 0 && commentslist.length > 0">
                <view class="spacing-nav-title">
                    <text class="line"></text>
                    <text class="text-wrapper">{{$t('fengcheche.cutprice.detail_base_title_pinglun_text')}}</text>
                    <navigator :url="'/pages/fcc/cutprice/commentlist/commentlist?goods_id=' + goods.id" hover-class="none"><view class="seemore">{{$t('fengcheche.cutprice.detail_see_more_text')}}</view></navigator>
                </view>
                <view class="pingluncc bg-white">
                    <view class="pinglunbox" v-for="(item, index) in commentslist" :key="index">
                        <view class="userhead">
                            <image :src="item.user.avatar || cutprice_static_url+'mini/default-user.png'" mode="aspectFill" />
                            <view class="whois">{{ item.user.user_name_view }}</view>
                        </view>

                        <view class="txt">{{ item.content }}</view>
                    </view>
                </view>
            </view>

            <!-- 商品详情 -->
            <view class="goods-detail spacing">
                <view class="spacing-nav-title">
                    <text class="line"></text>
                    <text class="text-wrapper">{{$t('fengcheche.cutprice.detail_base_title_xiangqing_text')}}</text>
                </view>
                <!-- 是否详情展示相册 -->
                <block v-if="common_is_goods_detail_show_photo == 1 && goods_photo.length > 0">
                    <view class="goods-detail-photo bg-white" v-for="(item, index) in goods_photo" :key="index">
                        <image
                            v-if="(item.images || null) != null"
                            @tap="goods_detail_images_view_event"
                            :data-value="item.images"
                            class="wh-auto dis-block"
                            :src="item.images"
                            mode="widthFix"
                        />
                    </view>
                </block>
                <!-- web详情 -->
                <view v-if="common_app_is_use_mobile_detail == 0" class="bg-white">
                    <rich-text :nodes="goods.content_web || ''"></rich-text>
                </view>
                <!-- 手机独立详情 -->
                <block v-if="common_app_is_use_mobile_detail == 1 && goods_content_app.length > 0">
                    <view class="goods-detail-app bg-white" v-for="(item, index) in goods_content_app" :key="index">
                        <image
                            v-if="(item.images || null) != null"
                            @tap="goods_detail_images_view_event"
                            :data-value="item.images"
                            class="wh-auto dis-block"
                            :src="item.images"
                            mode="widthFix"
                        />

                        <view v-if="(item.content || null) != null" class="content-items">
                            <view v-for="(items, index1) in item.content" :key="index1">{{ items }}</view>
                        </view>
                    </view>
                </block>
            </view>

            <!-- 结尾 -->
            <component-bottom-line :propStatus="data_bottom_line_status" :propMsg="$t('fengcheche.cutprice.data_bottom_line_msg')"></component-bottom-line>

            <!-- 底部操作 -->
            <view class="goods-buy-nav wh-auto bg-white bottom-line-exclude">
                <view class="item fl tc" @tap="shop_event">
                    <image :src="cutprice_static_url+'mini/goods-detail-home-icon.png'" mode="scaleToFill" />
                    <text class="dis-block cr-888">{{$t('fengcheche.cutprice.detail_base_home_text')}}</text>
                </view>
				<!-- 收藏 --> 
				<view class="item fl tc" @tap="goods_favor_event">
				    <image :src="cutprice_static_url+'mini/favor'+(nav_favor_button_info.status == 1 ? '-active' : '')+'-icon.png'" mode="scaleToFill"></image>
				    <text :class="'dis-block cr-888 ' + (nav_favor_button_info.status == 1 ? 'cr-main' : 'cr-gray')">{{nav_favor_button_info.text}}</text>
				</view>
                <view class="fr" :class="'cutprice-buy-nav-'+$t('fengcheche.cutprice.app_lang')">
                    <button class="bg-warning fl" type="default" @tap="popup_bang_event" hover-class="none">{{$t('fengcheche.cutprice.detail_base_title_guize_btn')}}</button>
                    <button class="bg-main fl" type="default" @tap="buy_submit_event" hover-class="none" :disabled="nav_submit_is_disabled">{{ nav_submit_text }}</button>
                </view>
            </view>

            <!-- 购买弹层 -->
            <component-popup :propShow="popup_status" propPosition="bottom" @onclose="popup_close_event">
                <view class="goods-popup bg-white bottom-line-exclude">
                    <view class="close fr oh">
                        <view class="fr" @tap.stop.prevent="popup_close_event">
                            <icon type="clear" size="20" />
                        </view>
                    </view>
                    <!-- 规格基础信息 -->
                    <view class="goods-popup-base oh br-b">
                        <image :src="goods_spec_base_images" mode="scaleToFill" class="br" @tap="goods_detail_images_view_event" :data-value="goods_spec_base_images" />
                        <view class="goods-popup-base-content">
                            <view class="goods-price">
                                <view class="sales-price">{{$t('fengcheche.cutprice.list_price_before')}}：{{ currency_symbol }}{{ goods_spec_base_price }}</view>
                                <view v-if="(goods_spec_base_original_price || null) != null && goods_spec_base_original_price > 0" class="original-price">
                                    {{$t('fengcheche.cutprice.list_price_old_price')}}：{{ currency_symbol }}{{ goods_spec_base_original_price }}
                                </view>
                            </view>
                            <view class="inventory">
                                <text class="cr-888">{{$t('fengcheche.cutprice.detail_base_title_kucun_text')}}</text>
                                <text class="cr-666">{{ goods_spec_base_inventory }}</text>
                                <text class="cr-888">{{ goods.inventory_unit }}</text>
                            </view>
                        </view>
                    </view>

                    <view class="goods-popup-content">
                        <!-- 商品规格 -->
                        <view v-if="goods_specifications_choose.length > 0" class="goods-spec-choose">
                            <view class="item br-b" v-for="(item, key) in goods_specifications_choose" :key="key">
                                <view class="title">{{ item.name }}</view>

                                <view v-if="item.value.length > 0" class="spec">
                                    <block v-for="(items, keys) in item.value" :key="keys">
                                        <button
                                            @tap.stop.prevent="goods_specifications_event"
                                            :data-key="key"
                                            :data-keys="keys"
                                            type="default"
                                            size="mini"
                                            hover-class="none"
                                            :class="items.is_active + ' ' + items.is_dont + ' ' + items.is_disabled"
                                        >
                                            <image v-if="(items.images || null) != null" :src="items.images" mode="scaleToFill" />
                                            {{ items.name }}
                                        </button>
                                    </block>
                                </view>
                            </view>
                        </view>

                        <!-- 购买数量 -->
                        <view class="goods-buy-number oh" style="display: none">
                            <view class="title fl">{{$t('fengcheche.cutprice.detail_base_title_buynum_text')}}</view>
                            <view class="number-content tc oh">
                                <view @tap="goods_buy_number_event" class="number-submit tc cr-888 fl" data-type="0">-</view>
                                <input @blur="goods_buy_number_blur" class="tc cr-888 fl" type="number" :value="temp_buy_number" />
                                <view @tap="goods_buy_number_event" class="number-submit tc cr-888 fl" data-type="1">+</view>
                            </view>
                        </view>
                    </view>
                    <button class="goods-popup-submit bg-main" type="default" @tap.stop.prevent="goods_buy_confirm_event" hover-class="none">{{$t('fengcheche.cutprice.detail_base_enter_btn_text')}}</button>
                </view>
            </component-popup>

            <!-- 邀请规则弹层 -->
            <view class="guize-popup">
                <component-popup :propShow="popup_bang_status" propPosition="bottom" @onclose="popup_bang_close_event">
                    <view class="share-popup bg-white bottom-line-exclude">
                        <view class="close fr oh">
                            <view class="fr" @tap.stop.prevent="popup_bang_close_event">
                                <icon type="clear" size="20" />
                            </view>
                        </view>
                        <view v-if="goods != null && goods.guize != ''" class="share-popup-content bangpopup">
                            <view class="gz"><rich-text :nodes="goods.guize || ''"></rich-text></view>
                        </view>
						<view v-else class="share-popup-content bangpopup">
						    <view class="gz">{{$t('fengcheche.cutprice.detail_base_title_guize_big_1')}}</view>
						    <view class="gz">{{$t('fengcheche.cutprice.detail_base_title_guize_big_2')}}</view>
						</view>
                    </view>
                </component-popup>
            </view>
			
			<!-- 分享弹窗 -->
			<component-share-popup :diyTheme="diytheme" ref="share"></component-share-popup>
        </view>

        <!-- 提示信息 -->
        <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>

        <!-- 在线客服 -->
        <block v-if="goods != null">
            <component-online-service :propIsNav="true" :propCard="true" :propTitle="goods.title" :propImg="goods.images" :proPath="'/pages/fcc/cutprice/detail/detail?cut_id='+goods.id"></component-online-service>
        </block>
        <block v-else>
            <component-online-service :propIsNav="true"></component-online-service>
        </block>

        <!-- 购物车 -->
        <navigator url="/pages/fcc/cutprice/order/order" hover-class="none">
            <view class="common-quick-nav quick-nav-cart">
                <image :src="cutprice_static_url+'mini/mycut.png'" class="dis-block"></image>
            </view>
        </navigator>
		
		<component-popup :propShow="is_show_fcc_tips_popup_box" propPosition="center" @onclose="app_download_popup_close">
			<view v-if="is_show_fcc_tips_popup_box" class="fcc_tips_popup_box">
				<view class="mask flex-center">
					<view class="content botton-radius">
						<view class="content-top">
							<text class="content-top-text">{{$t('fengcheche.cutprice.wenxin_tips_title')}}</text>
						</view>
						<view class="content-body">
							<view class="title">
								<text>{{$t('fengcheche.cutprice.down_app_tips')}}</text>
							</view>
							<view class="footer flex-center">
								<button class="content-button" style="border: none;color: #fff;" plain @click="app_download_aciton" data-value="andriod">
									{{$t('fengcheche.downappbtn')}}
								</button>
							</view>
						</view>
				
						<image class="close-img" src="../../../../uni_modules/uni-upgrade-center-app/images/app_update_close.png"
							@click.stop="app_download_popup_close"></image>
					</view>
				</view>
			</view>
		</component-popup>
		
		<!-- #ifdef APP-PLUS -->
		<yk-authpup ref="authpup" type="top" @changeAuth="changeAuth" :permissionID="permissionID"></yk-authpup>
		<!-- #endif -->
    </view>
</template>

<script>
const app = getApp();
// #ifdef APP-PLUS
import ykAuthpup from "@/components/yk-authpup/yk-authpup";
// #endif
import componentQuickNav from "@/components/quick-nav/quick-nav";
import componentPopup from '@/pages/fcc/cutprice/popup/popup';
import componentBadge from '@/components/badge/badge';
import componentNoData from "@/components/no-data/no-data";
import componentBottomLine from "@/components/bottom-line/bottom-line";
import componentOnlineService from "@/components/online-service/online-service";
import componentCountdown from "@/pages/fcc/cutprice/public/countdown";
import { cutprice_base_info } from '@/pages/fcc/cutprice/public/common.js';
import componentSharePopup from "@/components/share-popup/share-popup";
import {system_base_info, clear_user_cach} from "@/common/js/common/common";

var cutprice_static_url = app.globalData.get_static_url('cutprice', true);
var common_static_url = app.globalData.get_static_url('common');
export default {
    components: {
		// #ifdef APP-PLUS
		ykAuthpup,
		// #endif
		componentQuickNav,
        componentPopup,
        componentBadge,
		componentCountdown,
		componentNoData,
		componentBottomLine,
		componentOnlineService,
		componentSharePopup
    },
    data() {
        return {
            currency_symbol: app.globalData.currency_symbol(),
			common_static_url: common_static_url,
			cutprice_static_url: cutprice_static_url,
            indicator_dots: false,
            indicator_color: 'rgba(0, 0, 0, .2)',
            indicator_active_color: '#666',
            autoplay: true,
            circular: true,
            data_bottom_line_status: false,
            data_list_loding_status: 1,
            data_list_loding_msg: '',
            params: null,
            goods: null,
            songoods: [],
            goods_photo: [],
            goods_specifications_choose: [],
            goods_content_app: [],
            popup_status: false,
            temp_buy_number: 1,
            buy_event_type: 'buy',
            nav_submit_text: {},
            nav_submit_is_disabled: true,
            groups_status_text: {},
            goods_spec_base_price: 0,
            goods_spec_base_original_price: 0,
            goods_spec_base_inventory: 0,
            goods_spec_base_images: {},
            goods_spec_base_price_old: 0,
            goods_video_is_autoplay: false,
            common_app_is_use_mobile_detail: 1,
            common_is_goods_detail_show_photo: 0,
            popup_share_status: false,
            common_app_is_online_service: 0,
            popup_bang_status: false,
			// 导航收藏按钮
			nav_favor_button_info: {
			    text: this.$t('goods-detail.goods-detail.dco1sc'),
			    status: 0,
			},

            // 倒计时
            daojishi_data: null,

            daojishi_is_show_time: true,
            daojishi_time_millisecond: 0,
            daojishi_count_timer: null,
            daojishi_count_timers: null,

            // 海报分享
            common_app_is_poster_share: 0,

            // 优惠劵
            plugins_coupon_data: null,

            // 购物车快捷导航
            quick_nav_cart_count: 0,

            // 站点模式
            common_site_type: 0,

            customer_service_tel: null,

            // 优惠劵领取
            temp_coupon_receive_index: null,

            temp_coupon_receive_value: null,
            commentslist: [],
            hours: {},
            minutes: {},
            seconds: {},
            length: 0,
            keys: [],
			permissionID:'',
			// 自定义分享信息
			share_info: {},
			// 多语言
			lang_info:{},
			diytheme: null,
			diysysbase: null,
			is_show_fcc_tips_popup_box:false,
        };
    },
    onLoad(params) {
        // 启动参数处理
        params = app.globalData.launch_params_handle(params); // 参数赋值,初始化

        this.setData({
            params: params
        });
        this.init();
    },
    // 下拉刷新
    onPullDownRefresh() {
        this.init();
    },
    methods: {
		// 加载之前
		init() {
			// 先获取语言基础信息
			cutprice_base_info()
			.then(data=>{
				this.init_before(data)
				.then(()=>{
					system_base_info()
					.then(data=>{
						this.sys_init(data);
						this.init_real();
						this.get_data_list();
					});
				});
			});
		},
		// 设置系统基础参数
		sys_init(data){
			this.setData({
				diytheme: data.diytheme,
				diysysbase: data.base,
			});
		},
		// 设置本页参数
		init_before(data){
			var self = this;
			return new Promise((resolve, reject) => {
				self.setData({
					lang_info: data.cutprice_lang_info,
					currency_symbol: app.globalData.get_config('currency_symbol'),
					common_app_is_online_service: app.globalData.get_config('config.common_app_is_online_service'),
				});
				
				resolve();
			});
		},
        // 获取数据列表
        init_real() {
            // 参数校验
            if ((this.params.cut_id || null) == null) {
                uni.stopPullDownRefresh();
                this.setData({
                    data_bottom_line_status: false,
                    data_list_loding_status: 2,
                    data_list_loding_msg: this.$t('fengcheche.cutprice.detail_id_is_wrong')
                });
            } else {
                var self = this; // 加载loding

                uni.showLoading({
                    title: this.$t('fengcheche.cutprice.loading_tips')
                });
                this.setData({
                    data_list_loding_status: 1
                });
                uni.request({
                    url: app.globalData.get_request_url('detail', 'index', 'cutprice'),
                    method: 'POST',
                    data: {
                        cut_id: this.params.cut_id
                    },
                    dataType: 'json',
                    header: {
                        'content-type': 'application/x-www-form-urlencoded'
                    },
                    success: (res) => {
                        uni.stopPullDownRefresh();
                        uni.hideLoading();
                        console.log(res);

                        if (res.data.code == 0) {
                            var data = res.data.data;
                            self.setData({
                                goods: data.goods,
								nav_favor_button_info: {
								    text: (data.goods.user_is_favor == 1 ? this.$t('goods-detail.goods-detail.by7052') : '') + this.$t('goods-detail.goods-detail.dco1sc'),
								    status: data.goods.user_is_favor,
								},
                                indicator_dots: data.goods.photo.length > 1,
                                autoplay: data.goods.photo.length > 1,
                                goods_photo: data.goods.photo,
                                goods_specifications_choose: data.goods.specifications.choose || [],
                                goods_content_app: data.goods.content_app || [],
                                temp_buy_number: data.goods.buy_min_number || 1,
                                data_bottom_line_status: true,
                                data_list_loding_status: 3,
                                goods_spec_base_price: data.goods.price,
                                goods_spec_base_original_price: data.goods.original_price,
                                goods_spec_base_inventory: data.goods.inventory,
                                goods_spec_base_images: data.goods.images,
                                goods_spec_base_price_old: data.goods.original_price,
                                common_app_is_use_mobile_detail: data.common_app_is_use_mobile_detail || 0,
                                common_is_goods_detail_show_photo: data.common_is_goods_detail_show_photo || 0,
                                daojishi_data: data.daojishi_data || null,
                                common_app_is_poster_share: data.common_app_is_poster_share || 0,
                                quick_nav_cart_count: data.common_cart_total || 0
                            }); 
							console.log(this.daojishi_data);
							// 标题
                            uni.setNavigationBarTitle({
                                title: data.goods.title
                            }); 
							
							// 不能选择规格处理
                            this.goods_specifications_choose_handle_dont(0); 
							
							// 购买按钮处理
                            var nav_submit_text = self.$t('fengcheche.cutprice.detail_base_single_buy_text');
                            var nav_submit_is_disabled = data.goods.is_shelves == 1 && data.goods.inventory > 0 ? false : true;
                            var groups_status_text = self.$t('fengcheche.cutprice.detail_base_hd_status_ing');

                            if (data.goods.is_shelves != 1) {
                                nav_submit_text = self.$t('fengcheche.cutprice.detail_groups_status_down');
                                nav_submit_is_disabled = true;
                                groups_status_text = self.$t('fengcheche.cutprice.detail_groups_status_down');
                            } else {
                                if (data.goods.inventory <= 0) {
                                    nav_submit_text = self.$t('fengcheche.cutprice.detail_groups_status_off');
                                    nav_submit_is_disabled = true;
                                    groups_status_text = self.$t('fengcheche.cutprice.detail_groups_status_off');
                                }
                            }

                            if (parseInt(data.goods.status) > 1) {
                                nav_submit_text = self.$t('fengcheche.cutprice.detail_base_hd_over_tips');
                                nav_submit_is_disabled = true;
                                groups_status_text = self.$t('fengcheche.cutprice.detail_base_hd_over_tips');
                            } 
							
							// 活动倒计时
                            if (this.daojishi_data != null) {
                                //this.daojishi_countdown(); 
								
								// 即将开始的时候，按钮也是不能买的
                                if (this.daojishi_data.time.status == 0) {
                                    nav_submit_text = self.$t('fengcheche.cutprice.detail_groups_status_will');
                                    nav_submit_is_disabled = true;
                                    groups_status_text = self.$t('fengcheche.cutprice.detail_groups_status_will');
                                }
                            } 
							
							// 站点模式 - 是否展示型
                            var common_site_type = data.common_site_type || 0;

                            if (common_site_type == 1) {
                                nav_submit_text = self.$t('fengcheche.cutprice.detail_nav_submit_text_2');
                            } 

							// 数据赋值
                            this.setData({
                                nav_submit_text: nav_submit_text,
                                groups_status_text: groups_status_text,
                                nav_submit_is_disabled: nav_submit_is_disabled,
                                common_site_type: common_site_type,
                                customer_service_tel: data.customer_service_tel || null,
								share_info: {
								    title: data.goods.seo_title || data.goods.title,
								    kds: data.goods.seo_keywords || data.goods.simple_desc,
								    desc: data.goods.seo_desc || data.goods.simple_desc,
								    path: '/pages/fcc/cutprice/detail/detail',
								    query: 'cut_id=' + data.goods.id,
								    img: data.goods.images,
								    video: data.goods.video
								}
                            });
                        } else {
                            self.setData({
                                data_bottom_line_status: false,
                                data_list_loding_status: 0,
                                data_list_loding_msg: res.data.msg
                            });
                        }
						
						// 分享菜单处理
						app.globalData.page_share_handle(this.share_info);
                    },
                    fail: () => {
                        uni.stopPullDownRefresh();
                        uni.hideLoading();
                        self.setData({
                            data_bottom_line_status: false,
                            data_list_loding_status: 2,
                            data_list_loding_msg: this.$t('fengcheche.cutprice.request_data_error_tips')
                        });
                        app.globalData.showToast(this.$t('fengcheche.cutprice.request_data_error_tips'));
                    }
                });
            }
        },
		
		// 收藏事件
		goods_favor_event(e) {
		    if(!app.globalData.is_single_page_check()) {
		        return false;
		    }
		    var user = app.globalData.get_user_info(this, 'goods_favor_event', e);
		    if (user != false) {
		            uni.showLoading({
		                title: this.$t('common.processing_in_text'),
		            });
		            uni.request({
		                url: app.globalData.get_request_url('favor', 'favor', 'cutprice'),
		                method: 'POST',
		                data: {
		                    "id": this.goods.id
		                },
		                dataType: 'json',
		                success: res => {
		                    uni.hideLoading();
		                    if (res.data.code == 0) {
		                        this.setData({
		                        'goods.user_is_favor': res.data.data.status,
		                            nav_favor_button_info: {
		                                "text": res.data.data.text,
		                                "status": res.data.data.status
		                            }
		                        });
		                        app.globalData.showToast(res.data.msg, 'success');
		                    } else {
		                        if (app.globalData.is_login_check(res.data, this, 'goods_favor_event')) {
		                            app.globalData.showToast(res.data.msg);
		                        }
		                    }
		                },
		                fail: () => {
		                    uni.hideLoading();
		                    app.globalData.showToast(this.$t('common.internet_error_tips'));
		                }
		            });
		    }
		},

        // 获取评论列表
        get_data_list() {
            var self = this;
            uni.request({
                url: app.globalData.get_request_url('commentslist', 'index', 'cutprice'),
                method: 'POST',
                data: {
                    goods_id: this.params.cut_id,
                    page: 1,
                    number: 2
                },
                dataType: 'json',
                header: {
                    'content-type': 'application/x-www-form-urlencoded'
                },
                success: (res) => {
                    uni.hideLoading();
                    uni.stopPullDownRefresh();

                    if (res.data.code == 0) {
                        if (res.data.data.data.length > 0) {
                            this.setData({
                                commentslist: res.data.data.data
                            });
                        }
                    } else {
                        app.globalData.showToast(res.data.msg);
                    }
                },
                fail: () => {
                    uni.hideLoading();
                    uni.stopPullDownRefresh();
                    app.globalData.showToast(this.$t('fengcheche.cutprice.request_data_error_tips'));
                }
            });
        },

        // 不能选择规格处理
        goods_specifications_choose_handle_dont(key) {
            var temp_data = this.goods_specifications_choose || [];

            if (temp_data.length <= 0) {
                return false;
            } // 是否不能选择

            for (var i in temp_data) {
                for (var k in temp_data[i]['value']) {
                    if (i > key) {
                        temp_data[i]['value'][k]['is_dont'] = 'spec-dont-choose';
                        temp_data[i]['value'][k]['is_disabled'] = '';
                        temp_data[i]['value'][k]['is_active'] = '';
                    } // 当只有一个规格的时候

                    if (key == 0 && temp_data.length == 1) {
                        if ((temp_data[i]['value'][k]['is_only_level_one'] || null) != null && (temp_data[i]['value'][k]['inventory'] || 0) <= 0) {
                            temp_data[i]['value'][k]['is_disabled'] = 'spec-items-disabled';
                        } else {
                            temp_data[i]['value'][k]['is_disabled'] = '';
                        }
                    }
                }
            }

            this.setData({
                goods_specifications_choose: temp_data
            });
        },

        // 购买弹层关闭
        popup_close_event(e) {
            this.setData({
                popup_status: false
            });
        },

        // 进入店铺
        shop_event(e) {
			app.globalData.url_open('/pages/fcc/cutprice/index/index');
        },
		
		// 下载APP提示
		app_download_aciton(){
			// 获取用户设备类型
			const userAgent = navigator.userAgent.toLowerCase();
			let downloadUrl;
			console.log(userAgent);
			var url = this.diysysbase.app_download_url || null;
			if((url || null) == null)
			{
				app.globalData.showToast(this.$t('goods-detail.goods-detail.tq1976'));
			}
			// 判断是iOS还是Android设备
			if (/iphone|ipad|ipod/.test(userAgent)) {
				// iOS设备，跳转到App Store
				downloadUrl = this.diysysbase.app_download_url_ios || url;//'https://itunes.apple.com/us/app/your-app-name/idYOUR_APP_ID?mt=8'; // 替换YOUR_APP_ID为你的App Store应用ID
		
			}else if (/android/.test(userAgent)) {
				// Android设备，跳转到Google Play或其他应用商店
				// 这里以Google Play为例，但你可能需要根据用户的具体地区或设备类型调整链接
				downloadUrl = url; // 替换com.yourcompany.yourapp为你的Android应用包名
			} else {
				// 其他设备类型，可以处理或忽略
				downloadUrl = this.diysysbase.app_download_url_hong || url;
			}
			// 跳转到下载链接
			console.log(downloadUrl);
			//window.location.href = downloadUrl;
			// 浏览器跳转
			window.open(downloadUrl, '_blank'); 
		},
		
		app_download_popup_close()
		{
			this.setData({
			    is_show_fcc_tips_popup_box: false,
			});
		},

        // 发起砍价
        buy_submit_event(e) {
			var self = this;
			
			// 剪贴板
			uni.setClipboardData({
				data: 'linker-cutprice-open-'+self.goods.id,
				showToast: false,
				success: function () {}
			});
			// 同时存入缓存，目的在于若未登录，则APP内跳转登录后，返回是以此缓存来判断要返回的链接的
			uni.setStorageSync('linker_cut_data_cache_key', 'linker-cutprice-open-'+self.goods.id);
            this.setData({
                popup_status: true,
                buy_event_type: 'cart'
            });
        },

        // 加入购物车事件
        goods_cart_event(spec) {
            var user = app.globalData.get_user_info(this, 'goods_buy_confirm_event');

            if (user != false) {
				uni.showLoading({
					title: this.$t('fengcheche.cutprice.loading_process_tips')
				});
				uni.request({
					url: app.globalData.get_request_url('save', 'cart', 'cutprice'),
					method: 'POST',
					data: {
						goods_id: this.goods.id,
						stock: this.temp_buy_number,
						spec: JSON.stringify(spec)
					},
					dataType: 'json',
					success: (res) => {
						uni.hideLoading();

						if (res.data.code == 0) {
							app.globalData.clear_linker_cut_cache();
							
							this.popup_close_event();
							app.globalData.showToast(res.data.msg, 'success'); // 跳转到砍价详情去

							setTimeout(function () {
								app.globalData.url_open('/pages/fcc/cutprice/cart/detail/detail?id=' + res.data.data.cartid);
							}, 500);
						} else {
							if (app.globalData.is_login_check(res.data, this, 'goods_buy_confirm_event')) {
								app.globalData.showToast(res.data.msg);
							}
						}
					},
					fail: () => {
						uni.hideLoading();
						app.globalData.showToast(this.$t('fengcheche.cutprice.request_data_error_tips'));
					}
				});
            }
        },

        // 规格事件
        goods_specifications_event(e) {
            var key = e.currentTarget.dataset.key || 0;
            var keys = e.currentTarget.dataset.keys || 0;
            var temp_data = this.goods_specifications_choose;
            var temp_images = this.goods_spec_base_images; // 不能选择和禁止选择跳过

            if ((temp_data[key]['value'][keys]['is_dont'] || null) == null && (temp_data[key]['value'][keys]['is_disabled'] || null) == null) {
                // 规格选择
                for (var i in temp_data) {
                    for (var k in temp_data[i]['value']) {
                        if ((temp_data[i]['value'][k]['is_dont'] || null) == null && (temp_data[i]['value'][k]['is_disabled'] || null) == null) {
                            if (key == i) {
                                if (keys == k && (temp_data[i]['value'][k]['is_active'] || null) == null) {
                                    temp_data[i]['value'][k]['is_active'] = 'spec-active';

                                    if ((temp_data[i]['value'][k]['images'] || null) != null) {
                                        temp_images = temp_data[i]['value'][k]['images'];
                                    }
                                } else {
                                    temp_data[i]['value'][k]['is_active'] = '';
                                }
                            }
                        }
                    }
                }

                this.setData({
                    goods_specifications_choose: temp_data,
                    goods_spec_base_images: temp_images,
                    temp_buy_number: this.goods.buy_min_number || 1
                }); // 不能选择规格处理

                this.goods_specifications_choose_handle_dont(key); // 获取下一个规格类型

                this.get_goods_specifications_type(key); // 获取规格详情

                this.get_goods_specifications_detail();
            }
        },

        // 获取下一个规格类型
        get_goods_specifications_type(key) {
            var temp_data = this.goods_specifications_choose;
            var active_index = key + 1;
            var sku_count = temp_data.length;

            if (active_index <= 0 || active_index >= sku_count) {
                return false;
            } // 获取规格值

            var spec = [];

            for (var i in temp_data) {
                for (var k in temp_data[i]['value']) {
                    if ((temp_data[i]['value'][k]['is_active'] || null) != null) {
                        spec.push({
                            type: temp_data[i]['name'],
                            value: temp_data[i]['value'][k]['name']
                        });
                        break;
                    }
                }
            }

            if (spec.length <= 0) {
                return false;
            } // 获取数据

            uni.request({
                url: app.globalData.get_request_url('spectype', 'index', 'cutprice'),
                method: 'POST',
                data: {
                    id: this.goods.id,
                    spec: JSON.stringify(spec)
                },
                dataType: 'json',
                success: (res) => {
                    if (res.data.code == 0) {
                        var spec_count = spec.length;
                        var index = spec_count > 0 ? spec_count : 0;

                        if (index < sku_count) {
                            for (var i in temp_data) {
                                for (var k in temp_data[i]['value']) {
                                    if (index == i) {
                                        temp_data[i]['value'][k]['is_dont'] = '';
                                        var temp_value = temp_data[i]['value'][k]['name'];
                                        var temp_status = false;

                                        for (var t in res.data.data) {
                                            if (res.data.data[t] == temp_value) {
                                                temp_status = true;
                                                break;
                                            }
                                        }

                                        if (temp_status == true) {
                                            temp_data[i]['value'][k]['is_disabled'] = '';
                                        } else {
                                            temp_data[i]['value'][k]['is_disabled'] = 'spec-items-disabled';
                                        }
                                    }
                                }
                            }

                            this.setData({
                                goods_specifications_choose: temp_data
                            });
                        }
                    } else {
                        app.globalData.showToast(res.data.msg);
                    }
                },
                fail: () => {
                    app.globalData.showToast(this.$t('fengcheche.cutprice.request_data_error_tips'));
                }
            });
        },

        // 获取规格详情
        get_goods_specifications_detail() {
            // 是否全部选中
            var temp_data = this.goods_specifications_choose;
            var sku_count = temp_data.length;
            var active_count = 0; // 获取规格值

            var spec = [];

            for (var i in temp_data) {
                for (var k in temp_data[i]['value']) {
                    if ((temp_data[i]['value'][k]['is_active'] || null) != null) {
                        active_count++;
                        spec.push({
                            type: temp_data[i]['name'],
                            value: temp_data[i]['value'][k]['name']
                        });
                        break;
                    }
                }
            }

            if (spec.length <= 0 || active_count < sku_count) {
                this.setData({
                    goods_spec_base_price: this.goods.price,
                    goods_spec_base_original_price: this.goods.original_price,
                    goods_spec_base_inventory: this.goods.inventory
                });
                return false;
            } // 获取数据

            uni.request({
                url: app.globalData.get_request_url('specdetail', 'index', 'cutprice'),
                method: 'POST',
                data: {
                    id: this.goods.id,
                    spec: JSON.stringify(spec)
                },
                dataType: 'json',
                success: (res) => {
                    if (res.data.code == 0) {
                        this.setData({
                            goods_spec_base_price: res.data.data.price,
                            goods_spec_base_original_price: res.data.data.original_price,
                            goods_spec_base_inventory: res.data.data.inventory
                        });
                    } else {
                        app.globalData.showToast(res.data.msg);
                    }
                },
                fail: () => {
                    app.globalData.showToast(this.$t('fengcheche.cutprice.request_data_error_tips'));
                }
            });
        },

        // 数量输入事件
        goods_buy_number_blur(e) {
            var buy_number = parseInt(e.detail.value) || 1;
            this.setData({
                temp_buy_number: buy_number
            });
            this.goods_buy_number_func(buy_number);
        },

        // 数量操作事件
        goods_buy_number_event(e) {
            var type = parseInt(e.currentTarget.dataset.type) || 0;
            var temp_buy_number = parseInt(this.temp_buy_number);

            if (type == 0) {
                var buy_number = temp_buy_number - 1;
            } else {
                var buy_number = temp_buy_number + 1;
            }

            this.goods_buy_number_func(buy_number);
        },

        // 数量处理方法
        goods_buy_number_func(buy_number) {
            var buy_min_number = parseInt(this.goods.buy_min_number) || 1;
            var buy_max_number = parseInt(this.goods.buy_max_number) || 0;
            var inventory = parseInt(this.goods_spec_base_inventory);
            var inventory_unit = this.goods.inventory_unit;

            if (buy_number < buy_min_number) {
                buy_number = buy_min_number;

                if (buy_min_number > 1) {
                    app.globalData.showToast(this.$t('fengcheche.cutprice.detail_limit_buy_text') + buy_min_number + inventory_unit);
                }
            }

            if (buy_max_number > 0 && buy_number > buy_max_number) {
                buy_number = buy_max_number;
                app.globalData.showToast(this.$t('fengcheche.cutprice.detail_most_buy_text') + buy_max_number + inventory_unit);
            }

            if (buy_number > inventory) {
                buy_number = inventory;
                app.globalData.showToast(this.$t('fengcheche.cutprice.detail_base_stock_tips') + inventory + inventory_unit);
            }

            this.setData({
                temp_buy_number: buy_number
            });
        },

        // 确认
        goods_buy_confirm_event(e) {
            var user = app.globalData.get_user_info(this, 'goods_buy_confirm_event', e);

            if (user != false) {
				// 属性
				var temp_data = this.goods_specifications_choose;
				var sku_count = temp_data.length;
				var active_count = 0;
				var spec = [];

				if (sku_count > 0) {
					for (var i in temp_data) {
						for (var k in temp_data[i]['value']) {
							if ((temp_data[i]['value'][k]['is_active'] || null) != null) {
								active_count++;
								spec.push({
									type: temp_data[i]['name'],
									value: temp_data[i]['value'][k]['name']
								});
							}
						}
					}

					if (active_count < sku_count) {
						app.globalData.showToast(this.$t('fengcheche.cutprice.detail_base_spec_tips'));
						return false;
					}
				} 
				
				// 操作类型
				switch (this.buy_event_type) {
					case 'cart':
						this.goods_cart_event(spec);
						break;

					default:
						app.globalData.showToast(this.$t('fengcheche.cutprice.detail_base_buy_operation_tips'));
				}
            }
        },

        // 详情图片查看
        goods_detail_images_view_event(e) {
            var value = e.currentTarget.dataset.value || null;

            if (value != null) {
				if(app.globalData.is_android())
				{
					var self = this;
					uni.previewImage({
					    current: value,
					    urls: [value],
						longPressActions: {
							itemList: [self.$t('fengcheche.fcctips.t9')],
							success: function(data) {
								// 先关闭预览，否则会遮挡上方权限提醒
								uni.closePreviewImage();
								self.permissionID = 'WRITE_EXTERNAL_STORAGE';
								setTimeout(()=>{
									self.$refs['authpup'].open(value);
								},500);
							},
							fail: function(err) {
								console.log(err.errMsg);
							}
						}
					});
				}else{
					uni.previewImage({
					    current: value,
					    urls: [value]
					});
				}
            }
        },

        // 商品相册图片查看
        goods_photo_view_event(e) {
            var index = e.currentTarget.dataset.index;
            var all = [];

            for (var i in this.goods_photo) {
                all.push(this.goods_photo[i]['images']);
            }

			if(app.globalData.is_android())
			{
				var self = this;
				uni.previewImage({
					current: all[index],
					urls: all,
					longPressActions: {
						itemList: [self.$t('fengcheche.fcctips.t9')],
						success: function(data) {
							// 先关闭预览，否则会遮挡上方权限提醒
							uni.closePreviewImage();
							self.permissionID = 'WRITE_EXTERNAL_STORAGE';
							setTimeout(()=>{
								self.$refs['authpup'].open(all[index]);
							},500);
						},
						fail: function(err) {
							console.log(err.errMsg);
						}
					}
				});
			}else{
				uni.previewImage({
					current: all[index],
					urls: all
				});
			}
        },

        // 视频播放
        goods_video_play_event(e) {
            this.setData({
                goods_video_is_autoplay: true
            });
        },

        // 视频关闭
        goods_video_close_event(e) {
            this.setData({
                goods_video_is_autoplay: false
            });
        },
		
		// 分享开启弹层
		popup_share_event(e) {
		    if ((this.$refs.share || null) != null) {
		        this.$refs.share.init({
		            status: true,
		            share_info: this.share_info,
					is_goods_poster: this.common_app_is_poster_share,
					goods_id: this.goods.id,
					plugins_request: app.globalData.get_request_url('goodsposter', 'index', 'cutprice'),
		        });
		    }
		},

        // 规则开启弹层
        popup_bang_event(e) {
            this.setData({
                popup_bang_status: true
            });
        },

        // 规则弹层关闭
        popup_bang_close_event(e) {
            this.setData({
                popup_bang_status: false
            });
        },
		
		// #ifdef APP-PLUS
		//用户授权权限后的回调
		changeAuth(e){
			if(this.permissionID == 'WRITE_EXTERNAL_STORAGE')
			{
				// 直接下载
				app.globalData.save_image_by_url(e);
			}else{
				app.globalData.call_tel(this.customer_service_tel);
			}
		},
		// #endif
        // 展示型事件
        exhibition_submit_event(e) {
			if(app.globalData.is_android())
			{
				this.permissionID = 'CALL_PHONE';
				setTimeout(()=>{
					this.$refs['authpup'].open();
				},500);
			}else{
				app.globalData.call_tel(this.customer_service_tel);
			}
        }
    }
};
</script>
<style>
@import './detail.css';
</style>
